<template>
  <div class="app-container">
    <!-- 添加或修改服务记录对话框 -->
    <el-dialog title="开始服务" :visible.sync="open" width="50%" >
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="订单编号" prop="num">
              <el-input v-model="form.orderNo" :readonly="true" :disabled="true"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="经度" prop="x">
              <el-input v-model="form.x" placeholder="请输入经度" />
            </el-form-item>        
          </el-col>
          <el-col :span="12">
            <el-form-item label="纬度" prop="y">
              <el-input v-model="form.y" placeholder="请输入纬度" />
            </el-form-item>       
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="地址" prop="address">
              <el-input v-model="form.address" placeholder="请输入地址" />
            </el-form-item>  
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="照片" prop="imgUrl">
              <imageUpload v-model="form.imgUrl"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="结论" prop="remark">
              <div style="margin-top:5px;" v-for="item in checkReasonList" v-bind:key="item">
                <el-radio v-model="form.result" :label="item.dictLabel" border>{{item.dictValue}}</el-radio>
              </div>
              
            </el-form-item>
          </el-col>
          <el-col :span="12">
            
          </el-col>
        </el-row>
       
        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { startService, cancelOrder } from "@/api/business/order";
import ImageUpload from '@/components/ImageUpload';

export default {
  name: "Service",
  components: {
    ImageUpload
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      checkReasonList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderId: null,
        receiveId: null,
        receiveName: null,
        beginTime: null,
        endTime: null,
        imgUrl: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
  },
  methods: {
    init(data){
      this.reset();
      this.open = true;
      this.form.orderId = data.id;
      this.form.orderNo = data.num;
      this.getDicts("tb_check_reason").then(response => {
        this.checkReasonList = response.data;
      });
    },
   
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        orderId: null,
        orderNo: null,
        amount: 0,
        payWay: null,
        transNo: null,
        status: "0",
        payType: null,
        createTime: null,
        createUser: null,
        subject: "附加服务费",
        body: null,
        successTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
   
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {         
            startService(this.form).then(response => {
              this.msgSuccess("操作成功");              
              this.open = false;
              this.$emit("finishSelected"); 
            });
          
        }
      });
    },
   
  }
};
</script>
